<template>
  <div style="height:100%;width:100%;position:relative;">
      <div class="pagetop" ref="buttondiv">
          <template>
              <div>
                  <div style="float:left;width:100%" ref="line1Buttondiv">
                      <table style="font-size:12px;white-space: nowrap;" class="table1style">
                          <tr>
                              <td>分单类别</td>
                              <td>
                                  <rm-ddl-common datatype="reqgroup" dataname="分单类别" v-model="select_reqgroupval" width="180px" @change="ReqGroupChange" clearable filterable :appendtobody="true" visible-change:true></rm-ddl-common>
                              </td>
                              <td>申请项目</td>
                              <td>
                                  <rm-ddl-common datatype="reqitem" dataname="申请项目" v-model="select_reqitemval" width="180px" @change="ReqItemChange" clearable filterable :appendtobody="true" visible-change:true></rm-ddl-common>
                              </td>
                              <td :width="line1ButtonWidth"></td>

                              <td style="align:right">
                                  <el-button v-has="'PINQUERY'" icon="el-icon-search" type="primary" @click="btnQuery()">查询</el-button>
                              </td>
                              <td style="align:right">
                                  <el-button v-has="'PINQUERY'" icon="el-icon-thumb" @click="btnPlanTest()">测试</el-button>
                              </td>
                              <td style="align:right">
                                  <el-button icon="el-icon-edit-outline" @click="btnAdd" v-has="'PINQUERY'">新增</el-button>
                              </td>
                              <td style="align:right">
                                  <el-button icon="el-icon-edit" @click="btnEdit">修改</el-button>
                              </td>
                              <td style="align:right">
                                  <el-button icon="el-icon-delete-solid" @click="btnDel">删除</el-button>
                              </td>
                              <td style="align:right" @click="btnHoliday">
                                  <el-button icon="el-icon-cold-drink">节假日维护</el-button>
                              </td>
                          </tr>
                      </table>
                  </div>
              </div>
          </template>
      </div>
      <div class="pagecenter">
          <rm-layout-right splitcolor="#ffffff" :splitwidth="3" :fixsize="900" :minfixsize="200" :maxflxsize="1100">
              <vxe-table show-overflow ref="lXTable" class="mytable-style" height="auto" :loading="bLoading" :sort-config="{trigger: 'cell'}" :keyboard-config="keyConfig" :mouse-config="{selected: true}" :keyboard-local-config="keyLocalConfig" :data.sync="lXTableData" border size="mini" show-header-overflow highlight-current-row highlight-hover-row resizable stripe :edit-config="{
          trigger: 'click',
          mode: 'cell',
          showStatus: true,
          showIcon: false,
        }" header-align="center" :row-class-name="RowClassName" @current-change="CurrentChangeEvent">
                  <vxe-table-column field="plan_id" title="计划ID" align="center" width="50" sortable></vxe-table-column>
                  <vxe-table-column field="plan_code" title="计划代码" width="70" sortable>
                  </vxe-table-column>
                  <vxe-table-column field="plan_name" title="计划名称" width="220" sortable>
                  </vxe-table-column>
                  <vxe-table-column field="valid_flag" title="有效" width="40" align="center" sortable>
                      <template v-slot="{row}">
                          <el-checkbox v-if="row.valid_flag == '1'" checked="checked" :key="1" @change="InvalidFlag(row, 'valid_flag')" disabled></el-checkbox>
                          <el-checkbox v-else :key="0" @change="InvalidFlag(row, 'valid_flag')" disabled></el-checkbox>
                      </template>
                  </vxe-table-column>{
                  <vxe-table-column field="event_sourcename" title="触发动作" width="100" sortable>
                  </vxe-table-column>
                  <vxe-table-column field="event_source1name" title="补充触发动作" width="100" sortable>
                  </vxe-table-column>
                  <vxe-table-column field="event_destname" title="后续动作" width="100" sortable>
                  </vxe-table-column>
                  <vxe-table-column field="hospname" title="操作医院" align="center" width="200" sortable>
                  </vxe-table-column>
                  <vxe-table-column field="emer_flagname" title="急诊" width="40" align="center" sortable>
                  </vxe-table-column>
                  <vxe-table-column field="pat_typename" align="center" title="病人类型" width="80" sortable>
                  </vxe-table-column>
                  <vxe-table-column field="specimen_name" align="center" title="标本类型" width="80" sortable>
                  </vxe-table-column>
                  <!-- <vxe-table-column field="queuearea"
                                    title="采样区域"
                                    width="80"
                                    sortable>
                  </vxe-table-column> -->
                  <!-- <vxe-table-column field="create_username"
                                    title="创建人"
                                    width="120"
                                    sortable>
                  </vxe-table-column>
                  <vxe-table-column field="create_dt"
                                    title="创建时间"
                                    width="120"
                                    :formatter="['toDateString', 'yyyy/MM/dd HH:mm']"
                                    sortable>
                  </vxe-table-column>
                  <vxe-table-column field="modify_username"
                                    title="最后修改者"
                                    width="120"
                                    sortable>
                  </vxe-table-column>
                  <vxe-table-column field="modify_dt"
                                    title="最后修改时间"
                                    width="120"
                                    :formatter="['toDateString', 'yyyy/MM/dd HH:mm']"
                                    sortable>
                  </vxe-table-column> -->
                  <vxe-table-column field="input_code" title="录入码" width="120" sortable>
                  </vxe-table-column>
                  <vxe-table-column field="plan_typename" title="计划类型" width="130" sortable>
                  </vxe-table-column>
                  <vxe-table-column field="alert_name" title="预警时间" width="100" sortable>
                  </vxe-table-column>
                  <vxe-table-column field="skipholiday" title="跳过节假日" width="80" align="center" sortable>
                  </vxe-table-column>
                  <vxe-table-column field="perform_deptsname" title="执行科室" width="120" sortable>
                  </vxe-table-column>
                  <vxe-table-column field="description" title="备注说明" width="300" sortable>
                  </vxe-table-column>
              </vxe-table>
              <!-- 右侧数据 -->
              <template v-slot:fix>
                  <!-- 右上主表 -->
                  <el-tabs style="height:100%;" type="border-card" @tab-click="tab_getdata" v-model="tab_showflag">
                      <!-- 计划维护 -->
                      <el-tab-pane label="计划维护" name="tabname_plan_dict">
                          <div class="dict-right-top" style="border:1px solid #ccc;">
                              <el-form type="border-card" ref="detailData" :model="detailData" @submit.native.prevent :inline="true">
                                  <table width="100%" table style="font-size:12px;white-space: nowrap; text-align: right; align:;center;；" class="formstyle">
                                      <tr>
                                          <td style="color:#F56C6C;">计划代码</td>
                                          <td colspan="2">
                                              <el-input v-model="detailData.plan_code" :disabled="true"></el-input>
                                          </td>
                                          <td>计划类型</td>
                                          <td colspan="2">
                                              <el-input v-model="detailData.plan_typename" :disabled="true"></el-input>
                                          </td>
                                          <td>创建者</td>
                                          <td colspan="2">
                                              <el-input v-model="detailData.create_username" :disabled="true"></el-input>
                                          </td>
                                      </tr>
                                      <tr>
                                          <td style="color:#F56C6C;">计划名称</td>
                                          <td colspan="2">
                                              <el-input v-model="detailData.plan_name" :disabled="true"></el-input>
                                          </td>
                                          <td>提前</td>
                                          <td style="text-align: left;">
                                              <el-input v-model="detailData.alert_minutes" style="width:60px; " :disabled="true"></el-input>&nbsp;分钟未上机报警
                                          </td>
                                          <td style="text-align: left;color:#F56C6C;" colspan=""></td>
                                          <td>创建时间</td>
                                          <td colspan="2">
                                              <el-input v-model="detailData.create_dt" :disabled="true"></el-input>
                                          </td>
                                      </tr>
                                      <tr>
                                          <td style="color:#F56C6C;">触发事件</td>
                                          <td colspan="2">
                                              <el-input v-model="detailData.event_sourcename" :disabled="true"></el-input>
                                          </td>
                                          <td>录入码</td>
                                          <td colspan="2">
                                              <el-input v-model="detailData.input_code" :disabled="true"></el-input>
                                          </td>
                                          <td>最后修改者</td>
                                          <td colspan="2">
                                              <el-input v-model="detailData.modify_username" :disabled="true"></el-input>
                                          </td>
                                      </tr>
                                      <tr>
                                          <td>补充触发动作</td>
                                          <td colspan="2">
                                              <el-input v-model="detailData.event_source1name" :disabled="true"></el-input>
                                          </td>
                                          <td>跳过节假日</td>
                                          <td colspan="2">
                                              <el-select v-model="detailData.skipholiday" style="width:100%" :disabled="true">
                                                  <el-option v-for="(item, index) in skipholidayOpts" :key="index" :value="item.value" :label="item.label"></el-option>
                                              </el-select>
                                          </td>
                                          <td>最后修改时间</td>
                                          <td colspan="2">
                                              <el-input v-model="detailData.modify_dt" :disabled="true"></el-input>
                                          </td>
                                      </tr>
                                      <tr>
                                          <td style="color:#F56C6C;">后续动作</td>
                                          <td colspan="2">
                                              <el-input v-model="detailData.event_destname" :disabled="true"></el-input>
                                          </td>
                                          <td>有效性</td>
                                          <td colspan="2">
                                              <div v-if="detailData.valid_flag == 1">
                                                  <el-input value="有效" class="Stopuse" :disabled="true"></el-input>
                                              </div>
                                              <div v-else>
                                                  <el-input value="无效" class="Isuse" :disabled="true"></el-input>
                                              </div>
                                          </td>
                                      </tr>
                                      <tr>
                                          <td>触发条件限制</td>
                                      </tr>
                                      <tr>
                                          <td style="color:#F56C6C;">标本类型</td>
                                          <td colspan="2">
                                              <el-input v-model="detailData.specimen_name" :disabled="true"></el-input>
                                          </td>
                                          <td>执行科室</td>
                                          <td colspan="2">
                                              <el-input v-model="detailData.perform_deptsname" :disabled="true">
                                              </el-input>
                                          </td>
                                          <td style="color:#F56C6C;">急诊标志</td>
                                          <td colspan="2">
                                              <el-input v-model="detailData.emer_flagname" :disabled="true"></el-input>
                                          </td>
                                      </tr>
                                      <tr>
                                          <td style="color:#F56C6C;" v-if="detailData.revptflag=='1'">剔除病人类型</td>
                                          <td style="color:#F56C6C;" v-else>病人类型</td>
                                          <td colspan="2">
                                              <!-- <el-input v-model="detailData.pat_typename" :disabled="true"></el-input> -->
                                              <el-select v-model="detailData.pat_typecode" style="width:100%" :disabled="true">
                                                  <el-option v-for="(item, index) in pat_type_options" :key="index" :value="item.data" :label="item.display"></el-option>
                                              </el-select> &nbsp;&nbsp;
                                          </td>
                                          <td>采样区域</td>
                                          <td colspan="2">
                                              <el-select v-model="detailData.queuearea" style="width:100%" :disabled="true">
                                                  <el-option v-for="(item, index) in queueareaS_options" :key="index" :value="item.value" :label="item.label"></el-option>
                                              </el-select>
                                          </td>
                                          <td style="color:#F56C6C;">操作医院</td>
                                          <td colspan="2">
                                              <el-input v-model="detailData.hospname" :disabled="true"></el-input>
                                          </td>
                                      </tr>
                                      <tr>
                                          <td>备注说明</td>
                                          <td colspan="8">
                                              <el-input v-model="detailData.description" type="textarea" :rows="2" :disabled="true"></el-input>
                                          </td>
                                      </tr>
                                  </table>
                              </el-form>
                          </div>
                          <!-- 右下子表 -->
                          <div class="dict-right-bottom" style="border:1px solid #ccc">
                              <vxe-table show-overflow ref="rXTable" class="mytable-style" height="auto" :loading="bLoading" :sort-config="{trigger: 'cell'}" :keyboard-config="keyConfig" :keyboard-local-config="keyLocalConfig" :data.sync="rXTableData" border size="mini" show-header-overflow highlight-current-row highlight-hover-row resizable stripe :edit-config="{
                  trigger: 'click',
                  mode: 'cell',
                  showStatus: true,
                  showIcon: false,
                }" header-align="center">
                                  <vxe-table-column field="seq" title="序号" width="50" sortable>
                                  </vxe-table-column>
                                  <vxe-table-column title="当事件发生时间位于以下区间时" width="380" sortable>
                                      <vxe-table-column title="星期区间" width="100" sortable>
                                          <vxe-table-column field="weekday1name" title="起始" width="50" sortable>
                                          </vxe-table-column>
                                          <vxe-table-column field="weekday2name" title="结束" width="50" sortable>
                                          </vxe-table-column>
                                      </vxe-table-column>
                                      <vxe-table-column title="节假日期" width="110" sortable>
                                          <vxe-table-column field="holiday_dt" title="(屏蔽星期区间)" width="110" :formatter="['toDateString', 'yyyy/MM/dd']" sortable>
                                          </vxe-table-column>
                                      </vxe-table-column>
                                      <vxe-table-column title="时间区间" width="140" sortable>
                                          <vxe-table-column field="dt1" title="起始" width="60" sortable>
                                          </vxe-table-column>
                                          <vxe-table-column field="dt2" title="结束" width="60" sortable>
                                          </vxe-table-column>
                                      </vxe-table-column>
                                  </vxe-table-column>
                                  <vxe-table-column title="后续步骤预期发生时间为" width="220" sortable>
                                      <vxe-table-column title="向后延续到" width="90" sortable>
                                          <vxe-table-column field="dest_date_num" title="" width="50" align="right" sortable>
                                          </vxe-table-column>
                                          <vxe-table-column field="dest_date_unitname" title="" width="50" align="left" sortable>
                                          </vxe-table-column>
                                      </vxe-table-column>
                                      <vxe-table-column title="目标时间" width="140" sortable>
                                          <vxe-table-column field="dest_weekdayname" title="" width="60" sortable align="center">
                                          </vxe-table-column>
                                          <vxe-table-column field="dest_time" title="" width="60" sortable>
                                          </vxe-table-column>
                                      </vxe-table-column>
                                  </vxe-table-column>
                                  <vxe-table-column field="description" title="备注" width="400" sortable>
                                  </vxe-table-column>
                              </vxe-table>
                          </div>
                      </el-tab-pane>
                      <!-- 应用到分单类别 -->
                      <el-tab-pane label="应用到分单类别" style="overflow:scroll;" name="tabname_group_plan">
                          <div class="req-right-top" style="border:1px solid #ccc;">
                              <table style="font-size:12px;white-space: nowrap;" class="table1style">
                                  <tr>
                                      <td>
                                          <el-checkbox v-model="IsGroupSimilarPlan" @change="SimilarGroupPlan" style="color:red"></el-checkbox>
                                      </td>
                                      <td style="color:red;width:150px;white-space: nowrap;">
                                          仅显示无同类计划的数据
                                      </td>
                                      <td :width="line1ButtonWidth"></td>
                                      <td style="align:right">
                                          <el-button icon="el-icon-document-copy" @click="CopyGroupPlan">复制</el-button>
                                      </td>
                                      <td style="align:right">
                                          <el-button icon="el-icon-document-add" @click="OpenChosDlg('group')">粘贴</el-button>
                                      </td>
                                      <td style="align:right">
                                          <el-button type="primary" icon="el-icon-document" @click="SaveGroupPlan">保存</el-button>
                                      </td>
                                  </tr>
                              </table>
                          </div>
                          <div class="req-right-center" style="border:1px solid #ccc;">
                              <vxe-table show-overflow ref="xTable1" class="mytable-style" height="auto" :loading="bLoading" :sort-config="{trigger: 'cell'}" :keyboard-config="keyConfig" :mouse-config="{selected: true}" :keyboard-local-config="keyLocalConfig" :data.sync="reqgroupTD" border size="mini" show-header-overflow highlight-current-row :select-config="{reserve: true}" highlight-hover-row resizable stripe :edit-config="{trigger: 'click',mode: 'cell',showStatus: true,
                  showIcon: false,
                }" header-align="center">
                                  <vxe-table-column field="bgroupselect" title="" width="60" header-align="center" align="center" sortable>
                                      <template v-slot="{row}">
                                          <el-checkbox v-model="row.bgroupselect" true-label="1" false-label="0"></el-checkbox>
                                      </template>
                                  </vxe-table-column>

                                  <vxe-table-column field="req_groupname" title="分单类别名称" width="250" sortable>
                                  </vxe-table-column>
                                  <vxe-table-column field="plan_name" title="在用同类计划   " width="350" sortable>
                                  </vxe-table-column>
                                  <vxe-table-column field="req_groupcode" title="分单类别代码" width="100" sortable> </vxe-table-column>
                                  <vxe-table-column field="req_groupcode" title="分单类别ID" width="100" sortable>
                                  </vxe-table-column>
                              </vxe-table>
                          </div>
                      </el-tab-pane>
                      <!-- 应用到申请项目 -->
                      <el-tab-pane label="应用到申请项目" style="overflow:scroll;" name="tabname_item_plan">
                          <div class="req-right-top" style="border:1px solid #ccc;">
                              <table style="font-size:12px;white-space: nowrap;" class="table1style">
                                  <tr>
                                      <td>查询</td>
                                      <td>
                                          <el-input v-model="reqItemTxtSearch" placeholder="项目名称|项目代码|拼音码" style="width:200px"></el-input>
                                      </td>
                                      <td>分单类别</td>
                                      <td>
                                          <rm-ddl-common @change="itemGroupChange" datatype="reqgroup" dataname="分单类别" v-model="selGroupId" width="180px"></rm-ddl-common>
                                      </td>
                                      <td>
                                          <el-checkbox v-model="IsItemSimilarPlan" @change="SimilarItemPlan" style="color:red"></el-checkbox>
                                      </td>
                                      <td style="color:red;width:150px;white-space: nowrap;">
                                          仅显示无同类计划的数据
                                      </td>
                                      <td :width="line1ButtonWidth"></td>
                                      <td style="align:right">
                                          <el-button icon="el-icon-document-copy" @click="CopyReqItemPlan">复制</el-button>
                                      </td>
                                      <td style="align:right">
                                          <el-button icon="el-icon-document-add" @click="OpenChosDlg('reqitem')">粘贴</el-button>
                                      </td>
                                      <td style="align:right">
                                          <el-button type="primary" icon="el-icon-document" @click="SaveItemPlan">保存</el-button>
                                      </td>
                                  </tr>
                              </table>
                          </div>
                          <div class="req-right-center" style="border:1px solid #ccc;">
                              <vxe-table show-overflow ref="xTable2" class="mytable-style" height="auto" :loading="bLoading" :sort-config="{trigger: 'cell'}" :keyboard-config="keyConfig" :mouse-config="{selected: true}" :keyboard-local-config="keyLocalConfig" :data.sync="reqItemList" border size="mini" show-header-overflow highlight-current-row :select-config="{reserve: true}" highlight-hover-row resizable stripe :edit-config="{trigger: 'click',mode: 'cell',showStatus: true,showIcon: false,}" header-align="center" :key="reqkey">
                                  <vxe-table-column field="bitemselect" title="" width="60" header-align="center" align="center" sortable>
                                      <template v-slot="{row}">
                                          <el-checkbox v-model="row.bitemselect" true-label="1" false-label="0"></el-checkbox>
                                      </template>
                                  </vxe-table-column>
                                  <vxe-table-column field="req_itemcode" title="项目代码" width="100" sortable>
                                  </vxe-table-column>
                                  <vxe-table-column field="req_itemname" title="项目名称   " width="200" sortable>
                                  </vxe-table-column>
                                  <vxe-table-column field="plan_name" title="在用同类计划" width="350" sortable>
                                  </vxe-table-column>
                                  <vxe-table-column field="req_groupname" title="分单类别   " width="150" sortable>
                                  </vxe-table-column>
                                  <vxe-table-column field="inputcode" title="拼音码" width="100" sortable>
                                  </vxe-table-column>
                              </vxe-table>
                          </div>
                      </el-tab-pane>
                  </el-tabs>
              </template>
          </rm-layout-right>
      </div>
      <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" :title="dlgtitle" :visible.sync="bEditDlg" width="1000px" height="600px">
          <div>
              <div>
                  <el-form type="border-card" ref="dictDlgItem" :model="dictDlgItem" @submit.native.prevent :inline="true">
                      <table width="100%" table style="font-size:12px;white-space: nowrap;  align:;center;padding:8px;" class="dlgformstyle">
                          <tr>
                              <td style="color:#F56C6C;text-align: right;">计划代码</td>
                              <td colspan="2">
                                  <!-- :readonly="true" -->
                                  <el-input v-model="dictDlgItem.plan_code" ref="autofocus0" @keyup.enter.native="Funautofocus('autofocus0')" style="width:200px"></el-input>
                              </td>
                              <td style="text-align: right;">计划类别</td>
                              <td colspan="2">
                                  <el-input v-model="dictDlgItem.plan_typename" :disabled="true"></el-input>
                              </td>
                              <td style="text-align: right;">创建者</td>
                              <td colspan="2">
                                  <el-input v-model="dictDlgItem.create_username" :disabled="true" style="width:100%"></el-input>
                              </td>
                          </tr>
                          <tr>
                              <td style="color:#F56C6C;text-align: right;">计划名称</td>
                              <td colspan="2">
                                  <el-input v-model="dictDlgItem.plan_name" @change="getInput_Code" style="width:200px;text-align: left" ref="autofocus1" @keyup.enter.native="Funautofocus('autofocus1')"></el-input>
                              </td>
                              <td style="text-align: right;">提前</td>
                              <td style="text-align: left;">
                                  <el-input v-model="dictDlgItem.alert_minutes" style="width:60px; " ref="autofocus2" @keyup.enter.native="Funautofocus('autofocus2')"></el-input>&nbsp;分钟未上机
                              </td>
                              <td style="text-align: left;color:#F56C6C;" colspan=""></td>
                              <td style="text-align: right;">创建时间</td>
                              <td colspan="2">
                                  <el-input v-model="dictDlgItem.create_dt" :disabled="true" style="width:100%"></el-input>
                              </td>
                          </tr>
                          <tr>
                              <td style="color:#F56C6C;text-align: right;">触发动作</td>
                              <td style="text-align: left;" colspan="2">
                                  <el-select v-model="dictDlgItem.event_source" placeholder="" style="width:200px" ref="autofocus3" @keyup.enter.native="Funautofocus('autofocus3')">
                                      <el-option v-for="(item, index) in event_source_options" :key="index" :value="item.value" :label="item.label"></el-option>
                                  </el-select>
                              </td>
                              <td style="text-align: right;">录入码</td>
                              <td colspan="2">
                                  <el-input v-model="dictDlgItem.input_code" ref="autofocus4" @keyup.enter.native="Funautofocus('autofocus4')"></el-input>
                              </td>
                              <td style="text-align: right;">最后修改者</td>
                              <td colspan="2">
                                  <el-input v-model="dictDlgItem.modify_username" :disabled="true" style="width:100%"></el-input>
                              </td>
                          </tr>
                          <tr>
                              <td style="text-align: right;">补充触发动作</td>
                              <td style="text-align: left;" colspan="2">
                                  <el-select v-model="dictDlgItem.event_source1" placeholder="" style="width:200px" ref="autofocus5" @keyup.enter.native="Funautofocus('autofocus5')">
                                      <el-option v-for="(item, index) in event_source1_options" :key="index" :value="item.value" :label="item.label"></el-option>
                                  </el-select>
                              </td>

                              <td style="text-align: right;">跳过节假日</td>
                              <td colspan="2" style="text-align: left;">
                                  <el-select v-model="dictDlgItem.skipholiday" placeholder="" style="width:100%" ref="autofocus6" @keyup.enter.native="Funautofocus('autofocus6')">
                                      <el-option v-for="(item, index) in skipholidayOpts" :key="index" :value="item.value" :label="item.label"></el-option>
                                  </el-select>
                              </td>
                              <td style="text-align: right;">最后修改时间</td>
                              <td colspan="2">
                                  <el-input v-model="dictDlgItem.modify_dt" :disabled="true" style="width:100%"></el-input>
                              </td>
                          </tr>
                          <tr>
                              <td style=" color:#F56C6C;text-align: right;">后续动作</td>
                              <td style="text-align: left;" colspan="2">
                                  <el-select v-model="dictDlgItem.event_dest" placeholder="" style="width:200px" ref="autofocus7" @keyup.enter.native="Funautofocus('autofocus7')">
                                      <el-option v-for="(item, index) in event_dest_options" :key="index" :value="item.value" :label="item.label"></el-option>
                                  </el-select>
                              </td>
                              <td style="text-align: right;color:#F56C6C;">有效性</td>
                              <td style="text-align: left;padding: 0 0 0 15px;">
                                  <template border:1px solid>
                                      <el-radio-group v-model="dictDlgItem.valid_flag" size="mini">
                                          <el-radio ref="autofocus8" @keyup.enter.native="Funautofocus('autofocus8')" label="1">有效</el-radio>
                                          <el-radio label="0">无效</el-radio>
                                      </el-radio-group>
                                  </template>
                              </td>
                          </tr>
                          <tr>
                              <td style="color:#010138;padding: 15px 0 10px 0 ;text-align: right;">
                                  触发条件限制
                              </td>
                          </tr>
                          <tr>
                              <td style="text-align: right;">标本类型</td>
                              <td style="text-align: left;" colspan="2">
                                  <el-select v-model="dictDlgItem.specimen_code" placeholder="" style="width:200px" ref="autofocus9" @keyup.enter.native="Funautofocus('autofocus9')">
                                      <el-option v-for="(item, index) in specimen_name_options" :key="index" :value="item.value" :label="item.label"></el-option>
                                  </el-select>
                              </td>
                              <td style="text-align: right;">执行科室</td>
                              <td colspan="2">
                                  <el-select v-model="dictDlgItem.perform_depts" placeholder="默认全部科室,双击开窗多选" @dblclick.native="popMultipleChk(dictDlgItem.perform_depts,'dictDlgItem.perform_depts',deptOption,'科室选择')" filterable clearable ref="autofocus10" style="width:100%" @keyup.enter.native="Funautofocus('autofocus10')">
                                      <el-option v-for="(item,index) in deptOption" :key="index" :value="item.data" :label="item.display">
                                      </el-option>
                                  </el-select>
                                  <!-- <rm-ddl-common datatype="dept" dataname="科室" v-model="dictDlgItem.perform_depts" :appendtobody="true" ref="autofocus10" width="100%"
                                      @keyup.enter.native="Funautofocus('autofocus10')"></rm-ddl-common> -->

                              </td>
                              <td style="color:#F56C6C;text-align: right;">急诊标志</td>
                              <td style="text-align: left;" colspan="2">
                                  <el-select v-model="dictDlgItem.emer_flag" placeholder="请选择" ref="autofocus11" @keyup.enter.native="Funautofocus('autofocus11')" style="width:100%">
                                      <el-option v-for="item in emer_flag_options" :key="item.value" :label="item.label" :value="item.value">
                                      </el-option>
                                  </el-select>
                              </td>
                          </tr>
                          <tr>
                              <td style="color:#F56C6C;text-align: right;" v-if="dictDlgItem.revptflag=='1'">剔除病人类型</td>
                              <td style="color:#F56C6C;text-align: right;" v-else>病人类型</td>
                              <td style="text-align: left;" colspan="2">
                                  <el-select v-model="dictDlgItem.pat_typecode" placeholder="" style="width:120px" ref="autofocus12" @keyup.enter.native="Funautofocus('autofocus12')" @dblclick.native="popMultipleChk(dictDlgItem.pat_typecode,'dictDlgItem.pat_typecode',pat_type_options,'病人类型选择')" filterable clearable>
                                      <el-option v-for="(item, index) in pat_type_options" :key="index" :value="item.data" :label="item.display"></el-option>
                                  </el-select> &nbsp;&nbsp;
                                  <el-checkbox v-model="dictDlgItem.revptflag" align="center" size="medium" true-label="1" false-label="0">剔除</el-checkbox>
                              </td>
                              <td style="text-align: right;">采样区域</td>
                              <td style="text-align: left;" colspan="2">
                                  <el-select v-model="dictDlgItem.queuearea" placeholder="" style="width:100%" ref="autofocus13" @keyup.enter.native="Funautofocus('autofocus13')">
                                      <el-option v-for="(item, index) in queuearea_options" :key="index" :value="item.value" :label="item.label"></el-option>
                                  </el-select>
                              </td>
                              <td style="color:#F56C6C;text-align: right;">操作医院</td>
                              <td style="text-align: left;" colspan="2">
                                  <rm-ddl-common datatype="hospital" dataname="医院" v-model="dictDlgItem.hospcode" width="100%" ref="autofocus14" @keyup.enter.native="Funautofocus('autofocus14')" :disabled="hospdisable"></rm-ddl-common>
                              </td>
                          </tr>
                          <tr>
                              <td style="text-align: right;">备注说明</td>
                              <td colspan="8">
                                  <el-input v-model="dictDlgItem.description" type="textarea" :rows="2" ref="autofocus15" @keyup.enter.native="Funautofocus('autofocus15')"></el-input>
                              </td>
                          </tr>
                      </table>
                  </el-form>
              </div>
              <div class="middle-center">
                  <vxe-table show-overflow ref="dlgXTable" class="mytable-style" height="auto" :loading="bLoading" :sort-config="{trigger: 'cell'}" :keyboard-config="keyConfig" :mouse-config="{selected: true}" :keyboard-local-config="keyLocalConfig" :data.sync="detailDlgTableData" border size="mini" show-header-overflow highlight-current-row highlight-hover-row resizable stripe :edit-config="{
            trigger: 'click',
            mode: 'cell',
            showStatus: true,
            showIcon: false,
          }" header-align="center" :cell-class-name="cellClassName">
                      <vxe-table-column field="seq" title="序号" width="50" sortable :edit-render="{name: 'input',    autoselect: true,attrs: {type: 'text'}}">
                      </vxe-table-column>
                      <vxe-table-column title="当事件发生时间位于以下区间时" width="200" sortable>
                          <vxe-table-column title="星期区间" sortable>
                              <vxe-table-column field="weekday1" title="起始" width="100" sortable :disabled="true">
                                  <template v-slot="{ row,column }">
                                      <el-select @change=getholiday(row,column) v-if="row.holiday_dt== ''||row.holiday_dt==null" v-model="row.weekday1">
                                          <el-option v-for="item in weekoption" :key="item.value" :label="item.label" :value="item.value">
                                          </el-option>
                                      </el-select>
                                      <el-input v-model="row.weekday1" v-else style="background-color:#F4F4F4" :disabled="true">
                                      </el-input>
                                  </template>
                              </vxe-table-column>
                              <!-- <vxe-table-column field="weekday1name" title="起始" width="90" sortable> -->

                              <!-- <el-input placeholder="禁止开窗" v-model="row.autoprint_rptstyleidname" v-else disabled>
                                          <template slot="append"><a href="javascript:void(0)" @click="RptStyleSetting(row.autoprint_rptstyleid)"><i class="el-icon-edit"></i></a></template>
                                      </el-input> -->
                              <vxe-table-column field="weekday2" title="结束" width="100" sortable :disabled="true">
                                  <template v-slot="{ row,column }">
                                      <el-select @change=getholiday(row,column) v-if="row.holiday_dt== ''||row.holiday_dt==null" v-model="row.weekday2">
                                          <el-option v-for="item in weekoption" :key="item.value" :label="item.label" :value="item.value">
                                          </el-option>
                                      </el-select>
                                      <el-input v-model="row.weekday2" v-else style="background-color:#F4F4F4" :disabled="true">
                                      </el-input>
                                  </template>
                              </vxe-table-column>
                          </vxe-table-column>
                          <vxe-table-column title="节假日期" width="110" sortable>
                              <vxe-table-column field="holiday_dt" title="(屏蔽星期区间)" width="110" :formatter="['toDateString', 'yyyy/MM/dd']" sortable>
                                  <template width="100" v-slot="{row}">
                                      <div class="block; padding:0px 0px 0px 0px">
                                          <el-date-picker v-model="row.holiday_dt" align="right" type="date" style="middle-center">
                                              <!-- :picker-options="pickerOptions" -->
                                          </el-date-picker>
                                      </div>
                                  </template>
                              </vxe-table-column>
                          </vxe-table-column>
                          <vxe-table-column title="时间区间" width="140" sortable>
                              <vxe-table-column field="dt1" title="起始" width="70" sortable>
                                  <template v-slot="{row}">
                                      <el-time-picker v-model="row.dt1" value-format="HHmm" format="HH:mm" placeholder="时间" width="30">
                                      </el-time-picker>

                                  </template>
                              </vxe-table-column>
                              <vxe-table-column field="dt2" title="结束" width="70" sortable>
                                  <template v-slot="{row}">
                                      <el-time-picker v-model="row.dt2" value-format="HHmm" format="HH:mm" placeholder="时间">
                                      </el-time-picker>
                                  </template>
                              </vxe-table-column>
                          </vxe-table-column>
                      </vxe-table-column>
                      <vxe-table-column title="后续步骤预期发生时间为" width="360" sortable>
                          <vxe-table-column title="向后延续到" width="140" sortable>
                              <vxe-table-column field="dest_date_num" title="" width="50" align="right" :edit-render="{name: 'input', autoselect: true,attrs: {type: 'text'}}" sortable>
                              </vxe-table-column>
                              <vxe-table-column field="dest_date_unit" title="" width="90" align="left" sortable>
                                  <template v-slot="{ row }">
                                      <el-select v-model="row.dest_date_unit" @change="ClearValue(row)">
                                          <el-option v-for="item in dateoption" :key="item.value" :label="item.label" :value="item.value">
                                          </el-option>
                                      </el-select>
                                  </template>
                              </vxe-table-column>
                          </vxe-table-column>
                          <vxe-table-column title="目标时间" width="200" sortable>
                              <vxe-table-column field="dest_weekday" title="" width="100" sortable>
                                  <template v-slot="{ row }">
                                      <el-select v-model="row.dest_weekday" v-if="row.dest_date_unit== 'WEEK'">
                                          <el-option v-for="item in weekoption" :key="item.value" :label="item.label" :value="item.value">
                                          </el-option>
                                      </el-select>
                                      <el-input v-model="row.dest_weekday" v-else row.dest_weekday='' style="background-color:#F4F4F4" :disabled="true">
                                      </el-input>
                                  </template>
                              </vxe-table-column>
                              <vxe-table-column field="dest_time" title="" width="100" sortable>
                                  <template v-slot="{ row }">
                                      <el-time-picker v-if="row.dest_date_unit== 'WEEK'||row.dest_date_unit=='DAY'" v-model="row.dest_time" value-format="HHmm" format="HH:mm" placeholder="时间">
                                      </el-time-picker>
                                      <el-input v-else style="background-color:#F4F4F4" :disabled="true">
                                      </el-input>
                                  </template>
                              </vxe-table-column>
                          </vxe-table-column>
                      </vxe-table-column>
                      <vxe-table-column field="description" title="备注" width="400" :edit-render="{name: 'input',    autoselect: true,attrs: {type: 'text'}}" sortable>
                      </vxe-table-column>
                  </vxe-table>
              </div>
          </div>
          <div style="text-align:right;padding-top:15px">
              <el-button @click="AddRow">新增明细</el-button>
              <el-button @click="DelRow">删除明细</el-button>
              <el-button @click="btnSave">确 定</el-button>
              <el-button @click="bEditDlg = false" :autofocus="true">取 消</el-button>
          </div>
      </el-dialog>
      <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="提示" :visible.sync="bDelDlg" width="500px" height="300px">
          <span>你确定删除这笔记录？</span>
          <span slot="footer" class="dialog-footer">
              <el-button @click="confirmDel">确 定</el-button>
              <el-button @click="bDelDlg = false" :autofocus="true">取 消</el-button>
          </span>
      </el-dialog>
      <!-- 节假日维护 -->
      <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="计划维护跳过节假日" :visible.sync="bHoliday" width="900px" height="500px">
          <rm-holiday holidaychecktype="skipholiday" holidaytitle="计划维护跳过节假日"></rm-holiday>
      </el-dialog>
      <!--多选弹窗--->
      <el-dialog width="900px" v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" :title="multichktitle" :visible.sync="dialogMultipleVisible" :destroy-on-close="true">
          <rm-SqlMultiple :leftOption="option1" :rightOption="option2" :name="fieldname" @change="closedialog"></rm-SqlMultiple>
      </el-dialog>
      <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="提示" :visible.sync="ChosPasteDlg" width="500px" height="300px">
          <span>请选择粘贴方式</span>
          <span slot="footer" class="dialog-footer">
              <el-button @click="PasteSet(1)">追 加</el-button>
              <el-button @click="PasteSet(2)">覆 盖</el-button>
              <el-button @click="ChosPasteDlg = false">取 消</el-button>
          </span>
      </el-dialog>
      <!-- 测试 -->
      <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="计划时间测试" :visible.sync="bPlanTestDlg" width="800px" height="600px">
          <div>
              <div>
                  <table width="100%" table style="font-size:12px;white-space: nowrap;  align:;center;padding:8px;" class="dlgformstyle">
                      <tr>
                          <td style="text-align: right;">条码号</td>
                          <td>
                              <!-- :readonly="true" -->
                              <el-input style="width:100%" v-model="testobj.barcode" ref="testbarcode" @focus="Focus($event)"></el-input>
                          </td>
                          <td style="text-align: right;">
                              <p v-if="truebarcode" style="color:blue">提示:</p>
                              <p v-else style="color:red"> 提示:</p>
                          </td>
                          <td>
                              <p v-if="truebarcode" style="color:blue">请输入条码号以测试目标报告时间。</p>
                              <p v-else style="color:red"> 条码号有误，请重新输入条码号。</p>
                          </td>
                      </tr>
                      <tr>
                          <td style="text-align: right;">触发动作</td>
                          <td>
                              <el-select v-model="testobj.event_source" placeholder="" style="width:100%" ref="testevent_source">
                                  <el-option v-for="(item, index) in event_source_options" :key="index" :value="item.value" :label="item.label"></el-option>
                              </el-select>
                          </td>
                          <td style="text-align: right;">触发时间</td>
                          <td>
                              <el-date-picker v-model="testobj.time_source" type="datetime" placeholder="选择日期时间" align="right" :picker-options="pickerOptions" style="width:100%" value-format="yyyy-MM-dd HH:mm" :clearable="false" ref="testtime_source">
                              </el-date-picker>
                          </td>
                          <td style="text-align: right;">
                              <el-button v-has="'PINQUERY'" icon="el-icon-search" @click="btnTestQuery()" type="primary">测试查询</el-button>
                          </td>
                      </tr>
                  </table>
              </div>
              <div class="test-middle-center">
                  <vxe-table show-overflow ref="patXTable" height="auto" :data.sync="patData" border size="mini" show-header-overflow highlight-current-row highlight-hover-row resizable stripe header-align="center">
                      <vxe-table-column field="emer_flag" sortable title="急" width="20" show-overflow align="center">
                          <template v-slot="{ row, rowIndex, columnIndex }">
                              <div :key="row.userno+rowIndex+columnIndex" v-if="row.emer_flag == '1'">
                                  <font color="red">急</font>
                              </div>
                              <div :key="row.userno+rowIndex+columnIndex" v-else>
                              </div>
                          </template>
                      </vxe-table-column>
                      <vxe-table-column field="pat_name" align="center" sortable title="病人姓名" width="80" show-overflow></vxe-table-column>
                      <vxe-table-column field="pat_sexname" align="center" sortable title="性别" width="35" show-overflow></vxe-table-column>
                      <vxe-table-column field="pat_agestr" align="center" sortable title="年龄" width="40" show-overflow></vxe-table-column>
                      <vxe-table-column field="req_groupna" sortable title="分单类别" width="100" show-overflow></vxe-table-column>
                      <vxe-table-column field="specimen_name" align="center" sortable title="标本类型" width="80" show-overflow></vxe-table-column>
                      <vxe-table-column field="pat_typename" title="病人类型" width="60px"></vxe-table-column>
                      <vxe-table-column field="sample_items" sortable title="申请项目(描述)" width="350" show-overflow></vxe-table-column>
                      <vxe-table-column field="pat_no" sortable title="病人号" width="150" show-overflow></vxe-table-column>
                      <vxe-table-column field="barcode" sortable title="条码号" width="100" show-overflow></vxe-table-column>
                      <vxe-table-column field="perform_deptname" sortable title="执行科室" width="150" show-overflow></vxe-table-column>
                      <vxe-table-column field="areana" sortable title="采样区域" width="100" show-overflow></vxe-table-column>
                      <vxe-table-column field="hospcode" sortable title="操作医院" width="180" show-overflow></vxe-table-column>
                  </vxe-table>
              </div>
              <div class="test-middle-center">
                  <vxe-table show-overflow ref="patTestXTable" height="auto" :data.sync="patTestData" border size="mini" show-header-overflow highlight-current-row highlight-hover-row resizable stripe header-align="center" :cell-class-name="patTestCellClassName">
                      <vxe-table-column field="event_dest" title="目标事件" width="100" align="center" sortable :formatter="formatFun"></vxe-table-column>
                      <vxe-table-column field="DestDT" title="目标时间" width="120" sortable></vxe-table-column>
                      <vxe-table-column field="description" title="备注" width="400" sortable></vxe-table-column>
                      <vxe-table-column field="plan_id" title="计划ID" align="center" width="50" sortable></vxe-table-column>
                      <vxe-table-column field="seq" title="序号" width="50" sortable></vxe-table-column>

                  </vxe-table>
              </div>
          </div>
      </el-dialog>
  </div>
</template>

<script>
import XEUtils from "xe-utils";
import RmHoliday from "@/components/rmcompents/rm_Holiday.vue";
XEUtils.mixin({
  // 自定义全局的格式化处理函数
  formatSelect(cellValue, list) {
      let item = list.find((item) => item.value == cellValue);
      return item ? item.label : "";
  },
});
export default {
  name: "MNG246",
  components: {
      RmHoliday,
  },
  data() {
      return {
          hospdisable: false,
          tableTempData: [],
          tableData: [],
          AddData: [],
          ModData: [],
          option1: [],
          option2: [],
          plan_code: "",
          fieldname: "",
          multichktitle: "",
          txtsearch: "",
          reqItemTxtSearch: "",
          selectallhistory: false,
          dayNow: "",
          com: "",
          tab_showflag: "tabname_plan_dict",
          tab_label: "计划维护",
          plan_id: 0,
          actionindex: "Q",
          event_source: "",
          event_dest: "",
          plan_code: "",
          detailcount: 1,
          valid_flag: "",
          fuzzyquery: "",
          truebarcode: true,
          dialogMultipleVisible: false,
          IsGroupSimilarPlan: false,
          IsItemSimilarPlan: false,
          bEditDlg: false,
          bDelDlg: false,
          bLoading: false,
          bHoliday: false,
          bPlanTestDlg: false,
          bAfterfirstloading: true,
          bAfterssloading: true,
          bQueryAll: true,
          isabled: false,
          iseditseq: false,
          dialogTableVisible: false,
          editSeq: "0",
          dlgFlag: 0,
          loginutype: "",
          tempindex: 0,
          sstempindex: 0,
          sstempindex: 0,
          ssCurrRowIndex: 0,
          dictDlgItem: {},
          oldformdata: {},
          tempData: [],
          lXTableData: [],
          rXTableData: [],
          detailDlgTableData: [],
          reqgroupTD: [],
          oReqgroupTD: [],
          reqitemTD: [],
          ssCurrRow: [],
          patData: [],
          patTestData: [],
          select_reqgroupval: "", //按分单类别搜索
          select_reqgroupname: "",
          select_reqitemval: "", //按申请项目搜索
          select_validflag: "", //按有效性搜索
          reqgroupval: "",
          reqgroupname: "",
          turnlabgroupname: "",
          employeename: "", //员工姓名
          Isvalidflag: "全部",
          line1ButtonWidth: "",
          line2ButtonWidth: "",
          seluserinfoname: "",
          dlgtitle: "",
          input: "",
          txtquicksearch: "",
          hospcode: "",
          selGroupId: "",
          selGroupName: "",
          detailData: {},
          eeDlgItem: {},
          eeform: {},
          testobj: {
              barcode: "",
              event_source: "",
              time_source: XEUtils.toDateString(new Date()),
          },
          options: [
              { value: "1", label: "周一" },
              { value: "2", label: "周二" },
              { value: "3", label: "周三" },
              { value: "4", label: "周四" },
              { value: "5", label: "周五" },
              { value: "6", label: "周六" },
              { value: "7", label: "周日" },
              { value: "9", label: "节假日" },
          ],
          pickerOptions: {
              shortcuts: [
                  {
                      text: "今天",
                      onClick(picker) {
                          picker.$emit("pick", new Date());
                      },
                  },
                  {
                      text: "昨天",
                      onClick(picker) {
                          const date = new Date();
                          date.setTime(date.getTime() - 3600 * 1000 * 24);
                          picker.$emit("pick", date);
                      },
                  },
                  {
                      text: "一周前",
                      onClick(picker) {
                          const date = new Date();
                          date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
                          picker.$emit("pick", date);
                      },
                  },
              ],
          },
          value: "",
          keyConfig: {
              isDel: true,
              isTab: true,
              isEdit: true,
          },
          keyLocalConfig: {
              isArrow: true,
          },
          bOpendlg: false,
          bDeptDlg: false,
          deptOption: [],
          event_source_options: [], //触发动作
          event_source1_options: [], //补充动作
          event_dest_options: [], //后续动作
          emer_flag_options: [
              { value: "A", label: "全部" },
              { value: "1", label: "急诊" },
              { value: "0", label: "常规" },
          ], //急诊标志
          weekoption: [
              { label: "周一", value: 1 },
              { label: "周二", value: 2 },
              { label: "周三", value: 3 },
              { label: "周四", value: 4 },
              { label: "周五", value: 5 },
              { label: "周六", value: 6 },
              { label: "周日", value: 7 },
              { label: "节假日", value: 9 },
          ],
          dateoption: [
              { label: "天", value: "DAY" },
              { label: "周", value: "WEEK" },
              { label: "小时", value: "HOUR" },
              { label: "分钟", value: "MINUTE" },
          ],
          skipholidayOpts: [
              { label: "不跳过", value: "0" },
              { label: "跳到节假日后第一天", value: "1" },
              { label: "增加跳过的节假日天数", value: "2" },
          ],
          pat_type_options: [], //病人类型
          specimen_name_options: [], //标本类型
          queuearea_options: [], //采样区域编辑
          queueareaS_options: [], //采样区域展示
          pickdept: "", //匹配执行科室
          deptLData: [],
          deptRData: [],
          reqkey: 0,
          GroupPlanCopyContext: [],//复制的“应用到分单类别”
          ReqItemPlanCopyContext: [],//复制的“应用到申请项目”
          pasteOperate: "",//复制粘贴的设置
          ChosPasteDlg: false,
          groupKey: 0,
      };
  },
  created() {
      this.btnQuery();
      this.ddl_pat_typecode();
      this.ddl_event();
      this.ddl_specimen_name();
      this.ddl_queuearea();
      this.initOption();
      this.$ddldata.IsAreaModeFun().then((r) => {
          this.loginutype = this.$tool.getSession(this.$tool.loginutype);
          if (this.loginutype == "G" && this.$ddldata.IsAreaMode) {
              this.hospdisable = false;
          } else {
              this.hospdisable = true;
          }
      });
  },
  mounted() {},
  updated() {
      this.getButtonWidth();
  },
  watch: {},
  computed: {
      reqItemList() {
          let filterName = this.reqItemTxtSearch.trim();
          if (filterName) {
              let rest = this.reqitemTD.filter((item) => {
                  return item.req_itemcode.toUpperCase().indexOf(filterName.toUpperCase()) > -1 || (item.inputcode ? item.inputcode.toUpperCase().indexOf(filterName.toUpperCase()) > -1 : false) || (item.req_itemname ? item.req_itemname.toUpperCase().indexOf(filterName.toUpperCase()) > -1 : false);
              });
              return rest;
          } else {
              return this.reqitemTD;
          }
      },
  },
  methods: {
      //添加节假日维护选择
      getholiday(row, column) {
          if (column.property == "weekday1") {
              if (row.weekday1 == 9) {
                  row.weekday2 = 9;
              } else {
                  if (row.weekday2 == 9) row.weekday2 = 7;
              }
          }
          if (column.property == "weekday2") {
              if (row.weekday2 == 9) {
                  row.weekday1 = 9;
              } else {
                  if (row.weekday1 == 9) row.weekday1 = 1;
              }
          }
      },
      getButtonWidth() {
          if (this.$refs.buttondiv) {
              this.line1ButtonWidth = this.$refs.line1Buttondiv.offsetWidth + "px";
          }
          if (this.$refs.detailButtondiv) {
              this.line2ButtonWidth = this.$refs.line2Buttondiv.offsetWidth + "px";
          }
      },
      //----------------- 计划时间测试 ----------------- //
      btnPlanTest() {
          this.testobj = {
              barcode: "",
              event_source: "",
              time_source: "",
          };
          this.patData = [];
          this.patTestData = [];
          //bPlanTestDlg 打开弹窗
          //top:1:条码号,
          //top:2:触发动作,时间,查询按钮
          //middle:Vxetable
          //标本信息(病人姓名,性别,年龄字串,病人号,条码号) 分单类别 项目 标本类型 病人类型 执行科室 采样区域 急诊标志 操作医院
          //bottom top 测试按钮
          //bottom Vxetable
          //目标事件 目标时间(由 ReqPlan.PlanTest  获取),备注,计划id,序号
          this.truebarcode = true;
          this.bPlanTestDlg = true;
          setTimeout(() => {
              this.$refs.testbarcode.focus();
          }, 30);
      },
      async btnTestQuery() {
          try {
              this.patData = [];
              this.patTestData = [];
              if (this.testobj.barcode == "") {
                  this.$message({
                      message: "请先填写条码号。",
                      type: "warning",
                  });
                  this.$refs.testbarcode.focus();
                  return false;
              }
              if (this.testobj.event_source == "") {
                  this.$message({
                      message: "请选择触发动作。",
                      type: "warning",
                  });
                  this.$refs.testevent_source.focus();
                  return false;
              }
              if (this.testobj.time_source == "") {
                  this.$message({
                      message: "请选择触发时间。",
                      type: "warning",
                  });
                  this.$refs.testtime_source.focus();
                  return false;
              }
              const res = await this.$tool.request({
                  url: "MNG/MNG2/MNG246",
                  method: "post",
                  data: {
                      action: "querytest_pat",
                      ...this.testobj,
                  },
              });
              if (res.errflag == "1") {
                  this.truebarcode = true;
                  this.patData = res.dt;
                  if (res.planflag == "1") {
                      let testdata = res.testList;
                      testdata.sort((a, b) => {
                          return a.seq - b.seq;
                      });
                      this.patTestData = testdata;
                      this.$message.success("查询条码号成功，查询计划测试时间成功。");
                  } else {
                      this.patTestData = [];
                      this.$message.success("查询条码号成功，计划测试时间无数据。");
                  }
              } else {
                  this.patData = [];
                  this.patTestData = [];
                  this.$message.error(res.errormsg);
                  this.truebarcode = false;
                  this.$refs.testbarcode.focus();
              }
          } catch (e) {
              this.$message.error(e);
              this.console.log(e);
          }
      },
      Focus(event) {
          //点击触发文本内容全选
          event.currentTarget.select();
      },
      patTestCellClassName() {
          //预留,添加目标时间为特殊颜色.
      },
      formatFun({ cellValue, column }) {
          if (column.property == "event_dest") {
              try {
                  let event_destname = this.event_dest_options.find((m) => m.value == cellValue);
                  if (event_destname != undefined && event_destname != null) {
                      return event_destname.label;
                  } else {
                      return cellValue;
                  }
              } catch {}
          }
      },
      //----------------- 查询类 ----------------- //
      btnQuery() {
          this.actionindex = "Q";
          this.AddData = [];
          this.ModData = [];
          this.btnQuery1();
      },
      btnQuery1() {
          this.bLoading = true;
          this.$tool
              .request({
                  url: "MNG/MNG2/MNG246",

                  method: "post",
                  data: {
                      action: "query_plan_dict",
                      req_groupid: this.select_reqgroupval,
                      req_itemcode: this.select_reqitemval,
                  },
              })
              .then((res) => {
                  let cData = res.Data;
                  if (res.Data.length > 0) {
                      this.lXTableData = res.Data;
                      if (this.lXTableData.length == 0) this.actionindex = "A";
                      if (this.actionindex == "Q") {
                          //查询
                          this.HightLightRow(cData[0]);
                      } else if (this.actionindex == "A") {
                          if (this.AddData.indexOf(this.plan_code) == -1) this.AddData.push(this.plan_code);
                          this.HightLightRow(
                              cData.filter((item) => {
                                  return item.plan_code == this.plan_code;
                              })[0]
                          );
                      } else if (this.actionindex == "M") {
                          //修改
                          if (this.ModData.indexOf(this.plan_id) == -1) {
                              this.ModData.push(this.plan_id);
                          }

                          this.HightLightRow(
                              cData.filter((item) => {
                                  return item.plan_id == this.plan_id;
                              })[0]
                          );
                      } else {
                          //删除
                          if (this.tempindex > 0) {
                              this.HightLightRow(cData[this.tempindex]);
                          } else {
                              this.HightLightRow(cData[0]);
                          }
                      }
                  } else {
                      this.selrow = null;
                  }
                  this.bLoading = false;
              })
              .catch((e) => {
                  this.bLoading = false;
                  this.$alert(e);
              });
      },
      //获取弹窗数据
      queryFormData(flag) {
          this.$tool
              .request({
                  url: "MNG/MNG2/MNG246",
                  method: "post",
                  data: {
                      action: "queryforupdate",
                      plan_id: this.plan_id,
                  },
              })
              .then((res) => {
                  this.dictDlgItem = res.RData1.Data[0];
                  this.oldformdata = XEUtils.clone(this.dictDlgItem, true);
                  this.pickdept = this.detailData.perform_deptsname;
                  this.detailDlgTableData = res.RData2.Data;
                  this.bLoading = false;
                  if (flag == 1) {
                      this.actionindex = "M";
                      this.dialogTitleEdit = "计划维护编辑页面";
                      if (!this.$ddldata.IsAreaMode && this.dictDlgItem.hospcode != "All") {
                          this.$confirm("检测到操作医院不是所有医院，是否自动修正医院？", "提示", {
                              confirmButtonText: "确定",
                              cancelButtonText: "取消",
                              focusCancelButton: false,
                              closeOnClickModal: true,
                              type: "warning",
                          }).then(() => {
                              this.dictDlgItem.hospcode = "All";
                          });
                      }
                      this.bEditDlg = true;
                      this.$nextTick(() => {
                          this.$refs.autofocus0.focus();
                      });
                  }
              })
              .catch((e) => {
                  console.log("error", e);
              });
      },
      //设置高亮选中行
      async HightLightRow(row) {
          if (!!row) {
              this.$refs.lXTable.setCurrentRow(row);
              this.plan_id = row.plan_id;
              this.detailData = row;
              await this.detailQuery(row);
          } else {
              this.$refs.lXTable.setCurrentRow(null);
              this.detailData = {};
              // this.tmpdetailData = {}
              this.rXTableData = [];
          }
      },
      detailQuery(row) {
          this.$tool
              .request({
                  url: "MNG/MNG2/MNG246",
                  method: "post",
                  data: {
                      action: "query_plan_dict_detail",
                      plan_id: this.plan_id,
                  },
              })
              .then((res) => {
                  for (let i = 0; i < res.Data.length; i++) {
                      res.Data[i].dt1 = res.Data[i].dt1.slice(0, 2) + ":" + res.Data[i].dt1.slice(2, 4);
                      res.Data[i].dt2 = res.Data[i].dt2.slice(0, 2) + ":" + res.Data[i].dt2.slice(2, 4);
                      if(res.Data[i].dest_time !=null)res.Data[i].dest_time = res.Data[i].dest_time.slice(0, 2) + ":" + res.Data[i].dest_time.slice(2, 4);
                  }
                  this.rXTableData = res.Data;
              })
              .catch((e) => {
                  console.log("error", e);
              });
      },
      //查询分单类别
      QueryReqGroupPlan() {
          this.$tool
              .request({
                  url: "MNG/MNG2/MNG246",
                  method: "post",
                  data: {
                      action: "query_req_group_plan",
                      plan_id: this.plan_id,
                      event_source: this.event_source,
                      event_dest: this.event_dest,
                      hospcode: this.hospcode,
                  },
              })
              .then((res) => {
                  if (this.IsGroupSimilarPlan) {
                      this.reqgroupTD = res.RData2.Data;
                      this.reqgroupTD.sort((b, a) => Number(a.bgroupselect) - Number(b.bgroupselect));
                  } else {
                      this.reqgroupTD = res.RData.Data;
                      this.reqgroupTD.sort((b, a) => Number(a.bgroupselect) - Number(b.bgroupselect));
                  }
              })
              .catch((e) => {
                  console.log("error", e);
              });
      },
      //查询申请项目
      QueryReqItemPlan() {
          this.$tool
              .request({
                  url: "MNG/MNG2/MNG246",
                  method: "post",
                  data: {
                      action: "query_req_item_plan",
                      plan_id: this.plan_id,
                      req_groupid: this.reqgroupval,
                      req_itemcode: this.select_reqitemval,
                      event_source: this.event_source,
                      event_dest: this.event_dest,
                      hospcode: this.hospcode,
                      selgroupid: this.selGroupId,
                  },
              })
              .then((res) => {
                  if (this.IsItemSimilarPlan) {
                      this.reqitemTD = res.RData2.Data;
                      this.reqitemTD.sort((b, a) => Number(a.bitemselect) - Number(b.bitemselect));
                      this.reqkey++;
                  } else {
                      this.reqitemTD = res.RData.Data;
                      this.reqitemTD.sort((b, a) => Number(a.bitemselect) - Number(b.bitemselect));
                      this.reqkey++;
                  }
              })
              .catch((e) => {
                  console.log("error", e);
              });
      },
      CurrentChangeEvent({ row, rowIndex }) {
          this.dictDlgItem = row;
          this.CurrentRowChange(row, rowIndex);
      },
      //行选中事件
      CurrentRowChange(row, rowIndex) {
          this.tempindex = rowIndex;
          this.plan_id = row.plan_id;
          this.event_source = row.event_source;
          this.event_dest = row.event_dest;
          this.hospcode = row.hospcode;
          this.detailData = row;
          this.detailQuery();
          this.QueryReqGroupPlan();
          this.QueryReqItemPlan();
      },
      //有效性
      InvalidFlag(row, col) {
          let iInvalidCell = row[col];
          row[col] = iInvalidCell == "1" ? 0 : 1;
      },
      //仅显示无同类计划数据
      SimilarGroupPlan({ row }) {
          this.QueryReqGroupPlan();
      },
      SimilarItemPlan({ row }) {
          this.QueryReqItemPlan();
      },
      //行CLASS
      RowClassName({ row, rowIndex }) {
          if (row.valid_flag == "0") {
              return "rm-alert";
          }
          if (this.AddData.indexOf(row.plan_code) > -1) {
              return "row-new";
          }
          if (this.ModData.indexOf(row.plan_id) > -1) {
              return "row-modify";
          }
      },
      popMultipleChk(e, fieldname, option, title) {
          let temp = XEUtils.clone(option, true);
          this.option1 = [];
          this.option2 = [];
          if (e != "" && e != null) {
              let k = e.split(",");
              k.forEach((item) => {
                  let ndata = temp.find((m) => m.data == item);
                  if (ndata != undefined && ndata != null) {
                      this.option2.push(ndata);
                  }
              });
              temp.forEach((item) => {
                  if (k.indexOf(item.data + "") < 0) {
                      this.option1.push(item);
                  }
              });
          } else {
              this.option1 = temp;
          }
          this.fieldname = fieldname;
          this.multichktitle = title;
          this.dialogMultipleVisible = true;
      },
      //单元格CLASS
      cellClassName({ row, column }) {},
      //删除按钮
      async confirmDel() {
          try {
              this.actionindex = "D";
              var delrow = this.$refs.lXTable.getCurrentRow();
              if (delrow) {
                  var alld = this.$refs.lXTable.tableData;
                  var rowindex = alld.indexOf(delrow);
                  this.$refs.lXTable.remove(delrow);
                  await this.btnSave().then(() => {
                      this.lXTableData.splice(rowindex, 1);
                      let havedata = this.$refs.lXTable.tableData;
                      if (havedata.length > 0) {
                          if (rowindex >= havedata.length) rowindex = havedata.length - 1;
                          let selectrow = havedata[rowindex];
                          this.HightLightRow(selectrow);
                      } else {
                          this.HightLightRow(false);
                      }
                  });
              }
          } catch (e) {
              console.log("error", e);
          }
      },
      //有效性
      validflag() {
          this.bQueryAll = false;
          if ((this.validflag = "有效")) {
              this.lXTableData = this.lXTableData.filter((item) => (item.valid_flag = 1));
          } else if ((this.validflag = "无效")) {
              this.lXTableData = this.lXTableData.filter((item) => (item.valid_flag = 0));
          } else if ((this.validflag = "全部")) {
          }
          this.lXTableData = record;
          this.tempindex = 0;
      },
      //弹窗功能 flag 1新增2编辑 3删除
      btnAdd() {
          this.actionindex = "A";
          this.dictDlgItem = {
              plan_id: null,
              hospcode: this.$ddldata.IsAreaMode ? this.$tool.getSession(this.$tool.selectedhis) : "All",
              plan_code: "",
              plan_name: "",
              plan_type: "REQ",
              plan_typename: "申请单计划[REQ]",
              event_source: "",
              event_dest: "",
              emer_flag: "A",
              pat_typecode: "A",
              specimen_code: "A",
              valid_flag: "1",
              create_user: "",
              create_dt: "",
              modify_user: "",
              modify_dt: "",
              input_code: "",
              description: "",
              alert_minutes: 5,
              event_source1: "",
              queuearea: null,
              skipholiday: "",
              perform_depts: "",
              create_username: "",
              modify_username: "",
              event_sourcename: "",
              event_source1name: "",
              event_destname: "",
              specimen_name: "",
              emer_flagname: "",
              revptflag: "0",
          };
          this.detailDlgTableData = [];
          this.dialogTitleAdd = "计划维护新增界面";
          this.bEditDlg = true;
          this.$nextTick(() => {
              this.$refs.autofocus0.focus();
          });
      },
      btnEdit() {
          var editrow = this.$refs.lXTable.getCurrentRow();
          if (editrow) {
              if (this.loginutype != "G" && this.hospcode == "All" && this.$ddldata.IsAreaMode) {
                  //弹窗提示
                  this.$alert("您不是管理员，不能修改医院代码为All的计划项目！", "提示", {
                      confirmButtonText: "确定",
                  });
                  return false;
              } else {
                  this.queryFormData(1);
              }
          } else {
              this.$message({
                  message: "请先选择要修改的的计划。",
                  type: "warning",
              });
          }
      },
      btnDel() {
          var delrow = this.$refs.lXTable.getCurrentRow();
          if (delrow) {
              this.queryFormData(2);
              if (this.loginutype != "G" && this.hospcode == "All" && this.$ddldata.IsAreaMode) {
                  //弹窗提示
                  this.$alert("您不是管理员，不能删除医院代码为All的计划项目！", "提示", {
                      confirmButtonText: "确定",
                  });
                  return false;
              } else {
                  this.dialogTitleDel = "计划维护删除";
                  this.bDelDlg = true;
              }
          } else {
              this.$message({
                  message: "请先选择要删除的计划。",
                  type: "warning",
              });
          }
      },
      btnHoliday() {
          this.bHoliday = true;
      },
      ReqGroupChange(code, name) {
          this.dialogflag = 0;
          this.select_reqgroupval = code;
          this.select_reqgroupname = name;
          this.btnQuery();
      },
      ItemGroupChange(code, name) {
          if (code)
              this.tableData = this.tableTempData.filter((item) => {
                  return item.req_groupid == code;
              });
          else this.tableData = this.tableTempData;
      },
      ReqItemChange(code) {
          this.dialogflag = 0;
          this.select_reqitemval = code;
          this.btnQuery();
      },
      Select_Validflag_Change(val) {
          let valflag;
          if (val == "1") {
              valflag = 1;
          } else if (val == "0") {
              valflag = 0;
          } else if (val == "全部") {
              valflag = 2;
          }
          this.select_validflag = valflag;
          this.btnQuery();
      },
      itemGroupChange(code, name) {
          this.selGroupId = code;
          this.selGroupName = name;
          this.QueryReqItemPlan();
      },
      //所属检验科室
      eeDlgItem_labdeptcode_change(code, name) {
          this.eeDlgItem.labdeptcode = code;
          this.eeDlgItem.labdeptname = name;
      },
      //操作医院
      eeDlgItem_hospitalname_change(code, name) {
          this.eeDlgItem.hospcode = code;
          this.eeDlgItem.hospitalname = name;
      },
      userinfochange(code, name) {
          this.$nextTick(() => {
              this.eeDlgItem.userno = code;
              this.eeDlgItem.employeename = name;
          });
      },
      //提交表单
      async btnSave() {
          try {
              let createuserno = this.$tool.getSession(this.$tool.loginuserno);
              this.InitDate();
              if (this.actionindex == "A") {
                  //新增
                  this.dictDlgItem.create_user = createuserno;
                  this.dictDlgItem.create_dt = this.dayNow;
                  this.dictDlgItem.modify_user = createuserno;
                  this.dictDlgItem.modify_dt = this.dayNow;
              } else if (this.actionindex == "M") {
                  //修改
                  this.dictDlgItem.modify_user = createuserno;
                  this.dictDlgItem.modify_dt = this.dayNow;
              }

              let tabledata = [];
              if (this.actionindex == "A" || this.actionindex == "M") {
                  //修改或新增
                  if (this.dictDlgItem.plan_code == "") {
                      this.$message({
                          message: "计划代码不能为空。",
                          type: "warning",
                      });
                      this.$refs.autofocus0.focus();
                      return false;
                  } else if (this.dictDlgItem.event_source == "") {
                      this.$message({
                          message: "触发动作不能为空。",
                          type: "warning",
                      });
                      this.$refs.autofocus3.focus();
                      return false;
                  } else if (this.dictDlgItem.event_dest == "") {
                      this.$message({
                          message: "后续动作不能为空。",
                          type: "warning",
                      });
                      this.$refs.autofocus7.focus();
                      return false;
                  } else if (this.dictDlgItem.hospcode == "") {
                      this.$message({
                          message: "操作医院不能为空。",
                          type: "warning",
                      });
                      this.$refs.autofocus14.focus();
                      return false;
                  }
                  let date = this.$refs.dlgXTable.tableData;
                  date.sort((a, b) => {
                      return a.seq - b.seq;
                  });
                  for (let i = 0, len = date.length; i < len; i++) {
                      let tempseq = (i + 1) * 10;
                      if (tempseq !== date[i].seq) {
                          date[i].seq = tempseq;
                      }
                  }
                  tabledata = this.$refs.dlgXTable.getRecordset();
                  var rm = this.$refs.dlgXTable.getRemoveRecords();
                  var upt = this.$refs.dlgXTable.getUpdateRecords();
                  var updateseq = "";
                  //! 新增数据不需要添加
                  // if (insrt.length > 0) {
                  //     insrt.forEach((e) => {
                  //         updateseq += "," + e.seq;
                  //     });
                  // }
                  if (rm.length > 0) {
                      rm.forEach((e) => {
                          updateseq += "," + e.seq;
                      });
                  }
                  if (upt.length > 0) {
                      upt.forEach((e) => {
                          updateseq += "," + e.odata.seq;
                      });
                  }
              }
              const res = await this.$tool.request({
                  url: "MNG/MNG2/MNG246",
                  method: "post",
                  data: {
                      action: "save",
                      utype: this.actionindex,
                      oldinfo: this.oldformdata,
                      newinfo: this.dictDlgItem,
                      plandictdetail: tabledata,
                      updateseq: updateseq,
                  },
              });
              this.bDelDlg = false;
              if (res.errcode == "1") {
                  this.$message.success("保存成功！");
                  if (this.actionindex == "A") {
                      this.plan_code = this.dictDlgItem.plan_code;
                  }

                  this.bEditDlg = false;
                  this.btnQuery1();
              } else {
                  this.$message.error("保存失败！" + res.errmsg);
              }
          } catch (e) {
              this.$message.error(e);
              this.bDelDlg = false;
              this.bEditDlg = false;
              console.log("e", e);
          }
      },
      //获取拼音码
      getInput_Code() {
          this.dictDlgItem.input_code = this.$pub.CreateInputcode(this.dictDlgItem.plan_name, this, 16);
      },
      //手工输入编号
      EditSeq(flag) {
          if (flag == "0") {
              this.isabled = false;
              this.iseditseq = false;
          } else {
              // this.dataFormid = true;
              this.isabled = true;
              this.iseditseq = true;
          }
      },
      IsEditSeq({ row, columnIndex }) {
          if (columnIndex == "4") {
              if (this.iseditseq) {
                  return true;
              } else {
                  return false;
              }
          } else {
              return true;
          }
      },
      //首行滚动选中
      GetTopRow_SaveSeq() {
          this.$nextTick(() => {
              let toTop = this.$refs.SaveseqXTable.tableData[0];
              this.$refs.SaveseqXTable.scrollToRow(toTop);
          });
      },
      //尾行滚动选中
      GetButtonRow_SaveSeq() {
          this.$nextTick(() => {
              var alldataLen = this.$refs.SaveseqXTable.tableData.length;
              let toButton = this.$refs.SaveseqXTable.tableData[alldataLen - 1];
              this.$refs.SaveseqXTable.scrollToRow(toButton);
          });
      },
      popcomchange(c, v) {
          this.eeDlgItem.userno = c;
          this.eeDlgItem.employeename = v;
          this.dialogTableVisible = false;
      },
      init_tabbutton() {
          this.tab_jbxx_button = "none";
          this.tab_ckzmx_button = "none";
          this.tab_wzjg_button = "none";
      },
      tab_getdata(tab, event) {
          this.init_tabbutton();
          this.tab_label = tab.label;
          if (tab.label == " 计划维护") {
          }
          if (tab.label == "应用到分单类别") {
              this.QueryReqGroupPlan();
          }
          if (tab.label == "应用到申请项目") {
              this.QueryReqItemPlan();
          }
      },
      ClearValue(row) {
          if (row.dest_date_unit == "DAY" || row.dest_date_unit == "HOUR" || row.dest_date_unit == "MINUTE") {
              row.dest_weekday = null;
              row.dest_time = "1200";
          }
          if (row.dest_date_unit == "HOUR" || row.dest_date_unit == "MINUTE") {
              row.dest_time = "";
          }
      },
      AddRow() {
          this.detailcount = 1;
          let tempdetailData = this.$refs.dlgXTable.tableData;
          if (tempdetailData.length > 0) {
              tempdetailData.forEach((item) => {
                  if (this.detailcount <= Number(item.seq / 10)) {
                      this.detailcount = Number(item.seq / 10) + 1;
                  }
              });
              var myDate = XEUtils.now();
          }
          let rowseq = this.detailcount * 10;
          this.$refs.dlgXTable.insert({
              seq: rowseq,
              weekday1: 1,
              weekday2: 7,
              holiday_dt: null,
              dt1: "0000",
              dt2: "2359",
              dest_date_num: "0",
              dest_date_unit: "DAY",
              dest_weekday: null,
              dest_time: "1200",
              description: "",
          });
          let rows = this.$refs.dlgXTable.tableData;
          let selectrow = "";
          for (var i = 0; i < rows.length; i++) {
              if (rows[i].seq == rowseq) {
                  selectrow = rows[i];
                  break;
              }
          }
          if (selectrow && selectrow != "") {
              this.$refs.dlgXTable.setCurrentRow(selectrow);
              this.$refs.dlgXTable.setActiveRow(selectrow, "seq");
          }
      },
      DelRow() {
          var delrow = this.$refs.dlgXTable.getCurrentRow();
          if (delrow) {
              var upt = this.$refs.dlgXTable.getUpdateRecords();
              if (upt.length > 0) {
                  upt.forEach((e) => {
                      if (e.odata._XID == delrow._XID) {
                          delrow.seq = e.odata.seq;
                      }
                  });
              }
              this.$refs.dlgXTable.remove(delrow);
              let havedata = this.$refs.dlgXTable.getTableData().fullData;
              if (havedata.length > 0) {
                  let selectrow = this.$refs.dlgXTable.getTableData().fullData[havedata.length - 1];
                  this.$refs.dlgXTable.setCurrentRow(selectrow);
              }
              var rm = this.$refs.dlgXTable.getRemoveRecords();
          } else {
              this.$message({
                  message: "请先选中要删除的计划时间",
                  type: "warning",
              });
          }
      },
      //触发事件
      ddl_event() {
          this.$tool
              .request({
                  url: "MNG/MNG2/MNG246",
                  method: "post",
                  data: {
                      action: "ddl_event",
                  },
              })
              .then((res) => {
                  this.event_source_options = res.dt;
                  this.event_source1_options = res.dt;
                  this.event_dest_options = res.dt;
              });
      },
      //病人类型下拉框
      ddl_pat_typecode() {
          this.$tool
              .request({
                  url: "MNG/MNG2/MNG246",
                  method: "post",
                  data: {
                      action: "ddl_pat_typecode",
                  },
              })
              .then((res) => {
                  this.pat_type_options = res.pr;
              });
      },
      //标本类型
      ddl_specimen_name() {
          this.$tool
              .request({
                  url: "MNG/MNG2/MNG246",
                  method: "post",
                  data: {
                      action: "ddl_specimen_name",
                  },
              })
              .then((res) => {
                  this.specimen_name_options = res.sp;
              });
      },
      //采样区域
      ddl_queuearea() {
          this.$tool
              .request({
                  url: "MNG/MNG2/MNG246",
                  method: "post",
                  data: {
                      action: "ddl_queuearea",
                  },
              })
              .then((res) => {
                  this.queuearea_options = res.rc;
                  this.queueareaS_options = res.rc;
              });
      },
      SaveGroupPlan() {
          if (this.loginutype != "G" && this.hospcode == "All" && this.$ddldata.IsAreaMode) {
              //弹窗提示
              this.$alert("您不是管理员，不能修改医院代码为All的计划！", "提示", {
                  confirmButtonText: "确定",
              });
              this.QueryReqGroupPlan();
              return false;
          } else {
              let xTable1date = this.$refs.xTable1.getRecordset(); //主表数据
              let upxTable1date = xTable1date.updateRecords;
              let addstr = "";
              let delstr = "";
              upxTable1date.forEach((item) => {
                  if (item.cdata.bgroupselect == "1") {
                      addstr += item.cdata.req_groupid + ",";
                  } else if (item.cdata.bgroupselect == "0") {
                      delstr += item.cdata.req_groupid + ",";
                  }
              });
              this.$tool
                  .request({
                      url: "MNG/MNG2/MNG246",
                      method: "post",
                      data: {
                          action: "savegroupplan",
                          addgroup: addstr,
                          delgroup: delstr,
                          plan_id: this.plan_id,
                          urec: upxTable1date,
                      },
                  })
                  .then((res) => {
                      if (res.errcode == "1") {
                          this.$message.success("保存成功！");
                          this.QueryReqGroupPlan();
                      } else {
                          this.$message.error("保存失败:" + res.errmsg);
                      }
                  });
          }
      },

      CopyGroupPlan(){
          if (this.reqgroupTD && this.reqgroupTD.length > 0) {
              this.GroupPlanCopyContext = XEUtils.clone(this.reqgroupTD,true);
              this.$message({
                      message: "复制成功",
                      type: "success",
              });
          } else {
              this.$message({
                      message: "未找到需要复制的分单类别！",
                      type: "warning",
              });
          }
      },
      PasteGroupPlan(ptype){
          if (this.GroupPlanCopyContext && this.GroupPlanCopyContext.length > 0){
              this.bLoading = true;
              this.reqgroupTD.forEach((item) => {
                  var copyItem = this.GroupPlanCopyContext.find((c) => c.req_groupcode == item. req_groupcode);
                  if(ptype == "1"){
                      //追加
                      if(item.bgroupselect == "0" && copyItem.bgroupselect == "1"){
                          item.bgroupselect = copyItem.bgroupselect;
                      }
                  }else if(ptype == "2"){
                      //覆盖
                      item.bgroupselect = copyItem.bgroupselect;
                  }
              });
              this.$refs.xTable1.sort("bgroupselect");
              this.bLoading = false;
              this.$message({
                      message: "粘贴成功",
                      type: "success",
              });
          }else{
              this.$message({
                  message: "无分单类别设置可以粘贴，请先点击复制！",
                  type: "warning",
              });
          }
          this.ChosPasteDlg = false;
      },
      CopyReqItemPlan(){
          if (this.reqItemList && this.reqItemList.length > 0) {
              this.ReqItemPlanCopyContext = XEUtils.clone(this.reqItemList,true);
              this.$message({
                      message: "复制成功",
                      type: "success",
              });
          } else {
              this.$message({
                      message: "未找到需要复制的申请项目！",
                      type: "warning",
              });
          }
      },
      PasteReqItemPlan(ptype){
          if (this.ReqItemPlanCopyContext && this.ReqItemPlanCopyContext.length > 0){
              this.bLoading = true;
              this.reqItemList.forEach((item) => {
                  var copyItem = this.ReqItemPlanCopyContext.find((c) => c.req_itemcode == item. req_itemcode);
                  if(ptype == "1"){
                      //追加
                      if(item.bitemselect == "0" && copyItem.bitemselect == "1"){
                          item.bitemselect = copyItem.bitemselect;
                      }
                  }else if(ptype == "2"){
                      //覆盖
                      item.bitemselect = copyItem.bitemselect;
                  }
              });
              this.$refs.xTable2.sort("bitemselect");
              this.bLoading = false;
              this.$message({
                      message: "粘贴成功",
                      type: "success",
              });
          }else{
              this.$message({
                  message: "无申请项目设置可以粘贴，请先点击复制！",
                  type: "warning",
              });
          }
          this.ChosPasteDlg = false;
      },
      OpenChosDlg(pkd){
          this.pasteOperate = pkd;
          this.ChosPasteDlg = true;
      },
      PasteSet(ptype){
          if(this.pasteOperate == "group"){
              this.PasteGroupPlan(ptype);
          }else if(this.pasteOperate == "reqitem"){
              this.PasteReqItemPlan(ptype);
          }
      },
      SaveItemPlan() {
          if (this.loginutype != "G" && this.hospcode == "All" && this.$ddldata.IsAreaMode) {
              //弹窗提示
              this.$alert("您不是管理员，不能修改医院代码为All的计划！", "提示", {
                  confirmButtonText: "确定",
              });
              this.QueryReqItemPlan();
              return false;
          } else {
              let substr = "";
              let subItem = this.reqitemTD.filter((item) => item.bitemselect == "1");

              subItem.forEach((item) => {
                  substr += item.req_itemcode + ",";
              });
              this.$tool
                  .request({
                      url: "MNG/MNG2/MNG246",
                      method: "post",
                      data: {
                          action: "saveitemplan",
                          substr: substr,
                          plan_id: this.plan_id,
                          selgroupid: this.selGroupId,
                      },
                  })
                  .then((res) => {
                      if (res.errcode == "1") {
                          this.$message.success("保存成功！");
                          this.QueryReqItemPlan();
                      } else {
                          this.$message.error("保存失败:" + res.errmsg);
                      }
                  });
          }
      },
      DeptDialog(flag) {
          if (flag == "1") {
              this.bOpendlg = true;
              this.dlgtitle = "科室代码多项选择";
              this.pickdept = this.detailData.perform_depts;
              this.DeptQuery();
              this.bDeptDlg = true;
          }
      },
      DeptQuery() {
          this.bDeptLoading = true;
          this.$tool
              .request({
                  url: "LIS/LIS8/LIS822",
                  method: "post",
                  data: {
                      action: "ddl_perform_depts",
                      qcode: this.txtquicksearch,
                      pickdept: this.pickdept,
                  },
              })
              .then((response) => {
                  this.deptLData = response.RData.Data;
                  this.deptRData = response.RData2.Data;
                  this.bDeptLoading = false;
              })
              .catch((e) => {
                  console.log("error", e);
                  this.bDeptLoading = false;
              });
      },
      DeptAllAddQuery() {
          this.bDeptLoading = true;
          this.$tool
              .request({
                  url: "LIS/LIS8/LIS822",
                  method: "post",
                  data: {
                      action: "bactallquery",
                      fitsgerms: this.pickdept,
                  },
              })
              .then((response) => {
                  this.deptLData = response.RData.Data;
                  this.deptRData = response.RData2.Data;
                  this.bDeptLoading = false;
              })
              .catch((e) => {
                  console.log("error", e);
                  this.bDeptLoading = false;
              });
      },
      async initOption() {
          try {
              const res = await this.$tool.request({
                  url: "LIS/LIS6/LIS610",
                  method: "post",
                  data: {
                      action: "initOption",
                  },
              });
              this.deptOption = res.deptOption;
          } catch (e) {
              this.$message.warning(e);
          }
      },
      DeptSave() {
          let len = this.$refs.deptRxTable.getTableData().fullData.length - 1;
          let text = "";
          let i = 0;
          if (len > -1) {
              for (i = 0; i <= len; i++) {
                  text += this.$refs.deptRxTable.getTableData().fullData[i].perform_depts + ",";
              }
          } else {
              text = "";
          }
          let textlen = text.length;
          text = text.substring(0, textlen - 1);
          this.detailData.perform_deptsname = text;
          this.bBactDlg = false;
      },
      Funautofocus(element) {
          if (element == "autofocus0") {
              this.$refs.autofocus1.focus();
          } else if (element == "autofocus1") {
              this.$refs.autofocus2.focus();
          } else if (element == "autofocus2") {
              this.$refs.autofocus3.focus();
          } else if (element == "autofocus3") {
              this.$refs.autofocus3.blur();
              this.$refs.autofocus4.focus();
          } else if (element == "autofocus4") {
              this.$refs.autofocus5.focus();
          } else if (element == "autofocus5") {
              this.$refs.autofocus5.blur();
              this.$refs.autofocus6.$el.focus();
          } else if (element == "autofocus6") {
              this.$refs.autofocus5.blur();
              this.$refs.autofocus7.focus();
          } else if (element == "autofocus7") {
              this.$refs.autofocus7.blur();
              this.$refs.autofocus8.$el.focus();
          } else if (element == "autofocus8") {
              this.$refs.autofocus9.focus();
          } else if (element == "autofocus9") {
              this.$refs.autofocus9.blur();
              this.$refs.autofocus10.focus();
          } else if (element == "autofocus10") {
              this.$refs.autofocus11.focus();
          } else if (element == "autofocus11") {
              this.$refs.autofocus11.blur();
              this.$refs.autofocus12.focus();
          } else if (element == "autofocus12") {
              this.$refs.autofocus12.blur();
              this.$refs.autofocus13.focus();
          } else if (element == "autofocus13") {
              this.$refs.autofocus13.blur();
              this.$refs.autofocus14.$refs.ddlmainSelect.focus();
          } else if (element == "autofocus14") {
              this.$refs.autofocus14.$refs.ddlmainSelect.blur();
              this.$refs.autofocus15.focus();
          }
      },
      Validflag_Change(val) {
          let valflag;
          if (val == "1") {
              valflag = 1;
          } else if (val == "0") {
              valflag = 0;
          } else if (val == "全部") {
              valflag = 2;
          }
          this.select_validflag = valflag;
          this.btnQuery();
      },
      AllAddQuery() {
          this.bDeptLoading = true;
          this.$tool
              .request({
                  url: "LIS/LIS8/LIS822",
                  method: "post",
                  data: {
                      action: "bactallquery",
                      fitsgerms: this.pickdept,
                  },
              })
              .then((response) => {
                  this.deptLData = response.RData.Data;
                  this.deptRData = response.RData2.Data;
                  this.bDeptLoading = false;
              })
              .catch((e) => {
                  console.log("error", e);
                  this.bDeptLoading = false;
              });
      },
      Weekevent() {
          if (row.holiday_dt != "" || null) {
          }
      },
      InitDate() {
          this.dayNow = "";
          var myDate = new Date(); //获取当前年份(2位)
          var year = myDate.getFullYear(); //获取完整的年份(4位,1970-????)
          var month = myDate.getMonth() + 1; //获取当前月份(0-11,0代表1月)
          var day = myDate.getDate(); //获取当前日(1-31)
          var hour = myDate.getHours();
          var minute = myDate.getMinutes();
          var second = myDate.getSeconds();
          var millisecond = myDate.getMilliseconds();
          if (month < 10) {
              month = "0" + month;
          }
          if (day < 10) {
              day = "0" + day;
          }
          if (hour < 10) {
              hour = "0" + hour;
          }
          if (minute < 10) {
              minute = "0" + minute;
          }
          if (second < 10) {
              second = "0" + second;
          }
          // if (second < 10) {
          //     millisecond = "0" + millisecond;
          //     if (millisecond < 100) {
          //         millisecond = "0" + millisecond;
          //     }
          // }

          this.dayNow = year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second;
          return this.dayNow;
      },
      //加载节假日
      LoadHoliday() {
          this.$tool
              .request({
                  url: "MNG/MNG2/MNG241",
                  method: "post",
                  data: {
                      action: "LoadHoliday",
                  },
              })
              .then((res) => {
                  if (res.errcode == "0") {
                      this.$message({
                          message: res.errmsg,
                          type: "warning",
                      });
                  } else {
                      let pagedata = this.$refs.hXTable.getTableData().fullData;
                      res.forEach((item) => {
                          let startdate = XEUtils.toDateString(item.startdate);
                          if (pagedata.length > 0) {
                              for (var i = 0; i < pagedata.length; i++) {
                                  if (pagedata[i].nosmpdt.indexOf(startdate) > -1) {
                                  } else {
                                      this.$refs.hXTable.insert({
                                          nosmpdt: startdate,
                                      });
                                  }
                              }
                          } else {
                              this.$refs.PopxTable2.insert({
                                  nosmpdt: startdate,
                              });
                          }
                      });
                      this.$message({
                          message: "节假日加载成功",
                          type: "success",
                      });
                  }
              })
              .catch((e) => {
                  console.log("error", e);
              });
      },
      weekforbid(row, column) {
          if (row.holiday_dt != "" || null) {
              row.weekday1 = "";
              row.weekday2 = "";
          }
      },
      closedialog(value, name) {
          if (value != "close") {
              if (name == "dictDlgItem.pat_typecode") this.dictDlgItem.pat_typecode = value;
              else if (name == "dictDlgItem.perform_depts") this.dictDlgItem.perform_depts = value;
          }
          this.dialogMultipleVisible = false;
      },
  },
};
</script>

<style scoped>
.pagetop {
  left: 0;
  right: 0;
  height: 36px;
  display: -webkit-box;
  -webkit-box-pack: left;
  -webkit-box-align: center;
  border: solid 1px #ccc;
  position: absolute;
  z-index: 99;
  text-align: left;
}
.pagecenter {
  position: absolute;
  top: 39px;
  width: 100%;
  left: 0;
  bottom: 2px;
  overflow: auto;
}
.dict-right-top {
  border: 1px;
  position: absolute;
  width: 100%;
  height: 288px;
  overflow: auto;
}
.dict-right-center {
  border: 1px;
  position: absolute;
  width: 100%;
  top: 316px;
  height: 37px;
  overflow: auto;
}
.dict-right-bottom {
  border: 1px;
  position: absolute;
  width: 100%;
  top: 291px;
  bottom: 1px;
  overflow: auto;
}
.req-right-top {
  /* background-color: pink; */
  border: 1px;
  position: absolute;
  width: 100%;
  height: 37px;
  overflow: auto;
}
.req-right-center {
  border: 1px;
  position: absolute;
  width: 100%;
  top: 42px;
  bottom: 1px;
  overflow: auto;
}
.poppagetop {
  width: 100%;
  height: 40px;
  -webkit-box-pack: left;
  -webkit-box-align: center;
  position: absolute;
  border: 1px solid #ccc;
  z-index: 999;
}
.poppagecenter {
  position: absolute;
  top: 28px;
  width: 100%;
  left: 0;
}
.popmiddle-left {
  background-color: aqua;
  position: absolute;
  height: 440px;
  width: 480px;
  left: 0px;
  overflow: auto;
}
.popmiddle-center {
  position: absolute;
  -webkit-box-align: center;
  height: 100%;
  left: 485px;
  right: 485px;
}
.popmiddle-right-center {
  position: absolute;
  top: 0;
  height: 400px;
  width: 520px;
  right: 0px;
  top: 16px;
}
.table1style tr td {
  padding: 3px 2px 0px 5px;
}
.formstyle tr td {
  padding: 0px 2px 2px 0px;
}
.dlgformstyle tr td {
  padding: 0px 0px 2px 0px;
}
.inuseinput {
  font-weight: 900;
  border: 0px;
}
.middle-center {
  height: 250px;
}
.test-middle-center {
  height: 200px;
  padding: 0 0 5px 0;
  border: 1px solid rgbargba(75, 35, 35, 0) portant;
}
/deep/.el-icon-date:before {
  content: "";
}
/deep/.el-icon-time:before {
  content: "";
}

/deep/.vxe-table--header .vxe-header--column {
  border-right: 1px solid #cccccc;
  border-bottom: 1px solid #ccc;
}
/deep/.el-input.is-disabled .el-input__inner {
  color: #000000;
  cursor: default;
}

/deep/ .mytable-style.vxe-table .vxe-body--column.col-orange {
  background-color: #ccc;
}
/deep/.el-radio__label {
  font-size: 12px;
  padding-left: 10px;
}
/deep/.el-input.is-disabled .el-input__inner {
  color: #000000;
  color: #000000;
  border: 0px;
  padding: 0 5px;
  cursor: default;
}
/deep/.el-textarea.is-disabled .el-textarea__inner {
  background-color: #ffffff;
  border-color: #ffffff;
  color: #000000;
  padding: 5px;
  cursor: default;
}
/deep/.el-checkbox__input.is-disabled.is-checked .el-checkbox__inner::after {
  border-color: #000000;
  cursor: default;
}
/deep/.el-checkbox__input.is-disabled.is-checked .el-checkbox__inner {
  cursor: default;
}
/deep/.el-checkbox__input.is-disabled + span.el-checkbox__label {
  color: #c0c4cc;
  cursor: not-allowed;
  cursor: default;
}
/deep/ tr.vxe-body--row.row-new {
  color: #cc6600;
}
/deep/ tr.vxe-body--row.row-modify {
  color: blue !important;
}
/deep/ .Stopuse.el-input__inner {
  color: red;
}
/deep/ .Isuse.el-input__inner {
  color: blue;
}
/deep/.middle-center tr td div .el-input__inner {
  border: 1px solid rgba(255, 254, 254, 0) !important;
  background-color: rgba(255, 254, 254, 0) !important;
}
/deep/.el-input--prefix .el-input__inner {
  padding-left: 3px;
}
/deep/.vxe-table .vxe-cell {
  white-space: normal;
  word-break: break-word;
  padding: 0 3px;
}
/deep/.el-textarea__inner {
  padding: 0px 5px;
}
</style>
